<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\UserDrugWarehouseSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '用户药品仓库';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-drug-warehouse-index">

    <br>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('创建新的用户药品仓库', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            'id',
            [
                'attribute'=>'user_id',
                'value'=>"user.name",
            ],
            [
                'attribute'=>'user_drug_id',
                'value'=>"userDrug.name",
            ],
            [
                'attribute'=>'user_supplier_id',
                'value'=>"userSupplier.name",
            ],
            'num',
            'in_price',
            'out_price',
//            'vip_price',
            'product_coding',
            'produce_time',
            'expired_time',
            [
                'attribute'=>'status',
                'value'=>function($data){
                    return $data->status == 1 ? '已显示' : '不显示';
                }
            ],
            [
                'class' => 'yii\grid\ActionColumn',
                'template'=>'{view}{update}{delete}{approve}',
                'buttons'=>[
                    'approve'=>function($url,$model,$key)
                    {
                        $options = [
                            'title'=>Yii::t('yii','审核'),
                            'aria-lable'=>Yii::t('yii','审核'),
                            'data-confirm'=>Yii::t('yii','确定更新这个状态吗?'),
                            'date-method'=>'post',
                            'date-pjax'=>'0',
                        ];
                        return Html::a('<span class="glyphicon glyphicon-check"></span>',$url,$options);
                    },
                ],
            ],
        ],

        'emptyText'=>'当前没有用户',
        'emptyTextOptions'=>['style'=>'color:red;font-weight:bold'],
        'layout'=>"{items}\n{pager}",
    ]); ?>
</div>
